// index.js
// 获取应用实例
const app = getApp()
var basePage = require('../../common/BasePage');
Page({
  behaviors: [basePage],
  tabIndex: 0,
  catIndex: 1,

  data: {
    bannerArr: [],
    articleArr: [], //头条通告列表
    areaData: [{
      title: '昆明总站',
      search: '',
      nav: [{
          icon: "../../../../assets/home/kmzf.png",
          text: "昆明直发"
        },
        {
          icon: "../../../../assets/home/ppyx.png",
          text: "品牌严选"
        },
        {
          icon: "../../../../assets/home/xszn.png",
          text: "新手指南"
        },
        {
          icon: "../../../../assets/home/hqzs.png",
          text: "行情走势"
        }
      ]
    }, {
      title: '西安分站',
      search: '',
      banner: [{
        img: "../../assets/test.jpg"
      }, {
        img: "../../assets/test.jpg"
      }]
    }, {
      title: '延安分站',
      search: '',
      banner: [{
        img: "../../assets/test.jpg"
      }, {
        img: "../../assets/test.jpg"
      }]
    }, {
      title: '广州分站',
      search: '',
      banner: [{
        img: "../../assets/test.jpg"
      }, {
        img: "../../assets/test.jpg"
      }]
    }]
  },

  onLoad() {
    //请求轮播图
    this.request({
      url: this.data.host + '/home/index/banner?from=index'
    }, this.get_banner_ok,null,this.req_article);//(队列请求)请求轮播图之后，接着请求通告
  },
   //请求头条通告
  req_article(){
    this.request({
      url: this.data.host + '/home/article/index?cate_id=1'
    }, this.get_article_ok);
  },
  // 渲染头条数据
  get_article_ok(res) {
    // console.log("get_article_ok", res);
    this.setData({
      articleArr: res.data
    })
  },
  //渲染轮播图数据
  get_banner_ok(res) {
    this.setData({
      bannerArr: res.data
    })
  },
  article_click({currentTarget}){
    console.log(currentTarget);
    wx.navigateTo({
      url: '../article/Index?article_id='+currentTarget.dataset.article_id,
    })
  },
  area_change({
    detail
  }) {
    console.log("area_change", detail);
  },
  login_reload() {
    console.log("首页重载方法");

  }
})